package demo3;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * Date: 2023-05-14
 * Time: 1:16
 */
public class Computer {
    public void open(){
        System.out.println("开机！");
    }
    public void close(){
        System.out.println("关机！");
    }

    //是否使用usb
    public void useDevice(IUSB iusb){
        iusb.openDevice();
        if(iusb instanceof Mouse){
            Mouse mouse = (Mouse)iusb;
            mouse.click();
        }else if(iusb instanceof KeyBoard){
            KeyBoard keyBoard =(KeyBoard) iusb;
            keyBoard.inPut();
        }
        iusb.closeDevice();
    }
}
